<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../header.inc"%>
	<title>门诊医生</title>
	<style type="text/css">
		body {
			padding-bottom: 40px;
		}
		.sidebar-nav {
			padding: 9px 0;
		}

		@media (max-width: 980px) {
			/* Enable use of floated navbar text */
			.navbar-text.pull-right {
				float: none;
				padding-left: 5px;
				padding-right: 5px;
			}
		}


	</style>
	<script type="text/javascript">
		//全选/不选
		function checkall() {
			$(".checkone").prop("checked",$("#checkall").prop("checked"))
		}

		function delBatch() {
			var ids=[];
			//被选中的复选框，取出每一个value值
			$(".checkone:checked").each(function () {
				ids.push($(this).val())
			})
			if(ids.length==0){
				alert("请勾选要删除的记录");
				return false;
			}
			if (!confirm("确认删除选中的记录？")) {
				return false;
			}
			//定义一个异步
			var object={
				url:"/hospital/doctor/delete?ids="+ids,
				type:"post",
				//
				success:function(data){
					alert(data.msg);
					if(data.code==200) {
						location.href = "/hospital/doctor";
					}
				}
			}
			//触发异步
			$.ajax(object);

		}

		function deleteOne(id) {
			if (!confirm("确认删除该行记录？")) {
				return false;
			}
			//定义一个异步
			var object={
				url:"/hospital/doctor/delete/"+id,
				type:"get",
				//
				success:function(data){
					alert(data.msg);
					if(data.code==200) {
						//重定向到列表
						location.href = "/hospital/doctor";
					}
				}
			}
			//触发异步
			$.ajax(object);
		}
	</script>
</head>
<body>

<form id="doctorForm" action="/hospital/doctor" method="get" class="definewidth m20">
	<table class="table table-bordered table-hover definewidth m10">
		<tr>
			<td width="10%" class="tableleft">医生姓名：</td>
			<td><input type="text" name="name" value="${name}"/></td>
			<td width="10%" class="tableleft">科室：</td>
			<td>
				<select name="department" >
					<option value="" >==请选择==</option>
					<option value="急诊科" ${department eq '急诊科' ?'selected':''}  >急诊科</option>
					<option value="儿科"  ${department eq '儿科' ?'selected':''}  >儿科</option>
					<option value="妇科"  ${department eq '妇科' ?'selected':''}  >妇科</option>
					<option value="皮肤科"  ${department eq '皮肤科' ?'selected':''}  >皮肤科</option>
					<option value="内分泌科"  ${department eq '内分泌科' ?'selected':''}  >内分泌科</option>
					<option value="牙科"  ${department eq '牙科' ?'selected':''}  >牙科</option>
				</select>
			</td>
		</tr>
		<tr>
			<td colspan="6">
				<center>
					<input  type="submit" class="btn btn-primary" value="查询"/>
					<input onclick="$('#doctorForm').resetForm()" type="button" class="btn btn-primary" value="清空"/>
				</center>
			</td>
		</tr>
	</table>
</form>

<table class="table table-bordered table-hover definewidth m10" >
	<thead>
	<tr>
		<th><input type="checkbox" id="checkall" onChange="checkall();"></th>
		<th>医生编号</th>
		<th>医生姓名</th>
		<th>联系方式</th>
		<th>所属科室</th>
		<th>操作</th>
	</tr>
	</thead>
	<tbody>
	<c:forEach items="${doctors.list}" var="doctor">
		<tr>
			<td>
				<input type="checkbox" value="${doctor.id}" class="checkone">
			</td>
			<td>${doctor.idNum}</td>
			<td>${doctor.name}</td>
			<td>${doctor.phone}</td>
			<td>${doctor.department}</td>
			<td>
				<a href="/hospital/doctor/edit/${doctor.id}">编辑</a>
				<a href="javascript:deleteOne('${doctor.id}')">删除</a>
			</td>
		</tr>
	</c:forEach>
	</tbody>
</table>

<table class="table table-bordered table-hover definewidth m10" >
	<tr>
		<th colspan="5">  <div class="inline pull-right page">
			<a href='/hospital/doctor' >首页</a>

			<a href='/hospital/doctor?pageNum=${doctors.isFirstPage?1:(doctors.pageNum-1)}'>上一页</a>

			<a href='/hospital/doctor?pageNum=${doctors.isLastPage?doctors.pages:(doctors.pageNum+1)}'>下一页</a>

			<a href='/hospital/doctor?pageNum=${doctors.pages}'>尾页</a>

			&nbsp;&nbsp;&nbsp;共<span class='current'>${doctors.total}</span>条记录,
			共<span class='current'>${doctors.pages}</span>页,
			当前第<span class='current'>${doctors.pageNum}</span>页

		</div>
			<div>
				<a href="/hospital/doctor/add" type="button" class="btn btn-success">添加新医生</a>
				<button type="button" class="btn btn-success" id="delAll" onclick="delBatch()">批量删除</button>
			</div>

		</th>
	</tr>
</table>
</body>
</html>
